<?php

namespace app\api\validate;

use think\Validate;

class Vote extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'site_id'=> 'require',
        'title'  => 'require|length:1,250',
        'vote_limit'=> 'require|min:1',
        'endtime'=> 'require|date',
        'campaign_id'=>'regex:^[\d,]+$',
        'content'=>'require',
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'site_id.require'=> '站点ID不可为空',
        'title.require'  => '标题不可为空',
        'title.length'   => '标题最长支持250字',
        'vote_limit.require'=>'每人投票人数不可空',
        'vote_limit.min'    => '每人投票人数最小为1',
        'endtime.require'   => '结束时间不可为空',
        'endtime.date'      => '结束时间请选择有效日期',
        'campaign_id.regex' => '参选人员参数规则不正确',
        'content.require'   => '活动内容不可为空',
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'add'       => [],
        'edit'      => [],
        'campaign'  => ['site_id','title','vote_limit','endtime','campaign_id'],
        'child'     => ['site_id','title','endtime'],
        'active'    => ['site_id','title','endtime','content'],
    ];
    
}
